package com.rent.rent_back_end.controller;

import com.rent.rent_back_end.common.Result;
import com.rent.rent_back_end.domain.Posts;
import com.rent.rent_back_end.service.PostsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @Author: 王榄
 * @Date: 2023/02/06/12:35
 * @Description:
 */
@RestController
@CrossOrigin
@RequestMapping("/posts")
public class PostsController {
    @Autowired
    private PostsService postsService;

    @GetMapping("{postsId}")
    public Result selectById(@PathVariable Integer postsId){
        Posts posts = postsService.selectById(postsId);
        return new Result(200,posts,"获取职位成功");
    }

    @PostMapping
    public Result selectByCondition(@RequestBody Map<String,String> post ){
        List<Posts> posts = postsService.selectByCondition(post.get("postAddress"), post.get("postName"));
        return new Result(200,posts,"获取职位成功");
    }
}
